#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char rabbit[16] = {'P','e','t','e','r'};
    cout << "String length is " << strlen(rabbit) << endl;
    for(int  i = 0 ; i < 16 ; i++ )
    {
        cout << i << ":" << +rabbit[i] <<"("<<rabbit[i] << ")" << endl;
    }
    //The following is a good example of array subscript out of bounds
    // The char acter array is out of bounds ,which will be obvious when printing 
    // if the character array ends with 0, it will be out of range
    // The compiler will not remind when the boundary is crossed
    char bad_pig[9] = {'P','e','p','p','a',' ','P','i','g'};
    char good_pig[10] =  {'P','e','p','p','a',' ','P','i','g','\0'};

    cout << "Rabbit is (" << rabbit << " ) " <<endl;
    cout << "Pig's bad name is (" << bad_pig  << " ) " << endl;
    cout << "Pig's good name is (" << good_pig << " ) " << endl;

    char name[10] = {'L','i','\0','S','.','0'};
    cout << strlen(name) << endl;
return 0;
}